<?php
/**
 * Created by PhpStorm.
 * User: huliren<huliren0516@163.com>
 * Date: 2017/10/27
 * Time: 15:32
 */
define("SITE_AUTH", 'recom-reward-list');

require '../../../common.inc.php';

use Mobile\RecomData;
use lib\core\AdminAction;

class reward extends AdminAction
{
    public function doDefault()
    {
        $res = \Center\SiteData::getDataByKey('RewardList');
        if ($res) {
            $data = unserialize($res);
        }
        if (!empty($_POST)) {
            $data = [];
            foreach ($_POST['UserNick'] as $k => $v) {
                $data[$k]['UserNick'] = $v;
                $data[$k]['Text'] = $_POST['Text'][$k];
            }
            \Center\SiteData::updateSiteData('RewardList', serialize($data));
        }
        $smarty = $this->app->page();
        $smarty->value('data', $data);
        $smarty->output('recom/reward.tpl');
    }
}

$app->run();